/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ListaJugadores.java
 *
 * Created on 29/10/2009, 10:20:57 PM
 */

package Cliente;

import Conexion.Pais;
import Conexion.SerializedObject;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.io.IOException;
import java.util.ArrayList;
import javax.swing.ImageIcon;


/**
 *
 * @author Beto
 */
public class ListaJugadores extends javax.swing.JFrame {
private ImageIcon a14 = new ImageIcon(".//paises//wow2.jpg");

 private ArrayList<String> juga;
 private String myName;
    /** Creates new form ListaJugadores */



    public ListaJugadores(String jugadores)throws IOException {
        initComponents();
        //C=new Cliente();
        this.setSize(new Dimension(375, 300));
         this.getContentPane().setLayout(null);
        jLabel2.setBounds(new Rectangle(0, 0, 375, 300));
        jLabel2.setIcon(a14);
       
        //this.setEnabled(true);
        this.myName=jugadores;
        System.out.println("hola");
        this.list1.add(jugadores);
        
       //this.jList1.add();
    //    mostrar();

        
    }
    public void mostrar(){
        this.setVisible(true);
    }
    /* public void Jugar(){
        

                
                boolean finJuego=false;
                System.out.println("Esperando Jugadores");
                SerializedObject so2=null;
                 //this.setVisible(false);
            //tab.setVisible(true);
                while(!finJuego){
                    so2=C.recibir();
                    System.out.println("Esperando Jugada");
                        try {
                            Thread.sleep(100);
                        } catch (InterruptedException ex) {

                        }

                    System.out.println("Alo1");
                    if(so2.getTipoM().equalsIgnoreCase("IDENTIFICAR")){
                        System.out.println("Su nombre es "+so2.getName());
                        System.out.println("Su turno es "+so2.getMensaje());
                    }

                    if(so2.getTipoM().equalsIgnoreCase("ESPERAR")){
                        ArrayList<Pais> mundo=new ArrayList<Pais>();
                        mundo =(ArrayList<Pais>)so2.getObject();
                        System.out.println("ESPERAR TURNO");
                        for(int i=0;i<mundo.size();i++){
                            System.out.println(mundo.get(i).getNombre()+" "+
                                    mundo.get(i).getJugador()+" "+mundo.get(i).getUnidades());
                        }
                    }
                    if(so2.getTipoM().equalsIgnoreCase("JUGAR")){
                        System.out.println("TU TURNO");

                        ArrayList<Pais> mundo=new ArrayList<Pais>();
                        mundo=(ArrayList<Pais>)so2.getObject();
                        System.out.println("Estado actual del Mundo");
                        for(int i=0;i<mundo.size();i++){
                            System.out.println(mundo.get(i).getNombre()+" "+
                                    mundo.get(i).getJugador()+" "+mundo.get(i).getUnidades());
                        }
                        System.out.println("Escriba el nombre del pais donde desea ubicar unidades");
                        String temp=null;

                        for(int i=0;i<mundo.size();i++){
                            if(mundo.get(i).getNombre().equalsIgnoreCase(temp)){
                                mundo.get(i).addUnidades();
                                mundo.get(i).setJugador(so2.getName());
                            }
                        }
                        for(int i=0;i<mundo.size();i++){
                            System.out.println(mundo.get(i).getNombre()+" "+
                                    mundo.get(i).getJugador()+" "+mundo.get(i).getUnidades());
                        }
                        SerializedObject so3=new SerializedObject();
                        so3.setObject(mundo);
                        C.enviar(so3);
                    }
                }
            }*/

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        list1 = new java.awt.List();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Jugadores");

        jLabel2.setText("jLabel2");

        list1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                list1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(169, 169, 169)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(126, 126, 126)
                        .addComponent(list1, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(181, 181, 181)
                        .addComponent(jLabel2)))
                .addContainerGap(96, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(list1, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(51, 51, 51)
                .addComponent(jLabel2)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void list1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_list1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_list1ActionPerformed

    /**
    * @param args the command line arguments
    */
    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private java.awt.List list1;
    // End of variables declaration//GEN-END:variables

    void actualizar(ArrayList so2) {
        juga=so2;
        this.list1.removeAll();
        this.list1.add(this.myName);
        for(int i=0;i<juga.size();i++){
            this.list1.add(juga.get(i),i+1);
        }
    }
    public static void main(String args[]) throws IOException{
        
        ListaJugadores p=new ListaJugadores("beto");
        p.setVisible(true);

    }

}
